Return Values and Their Types

Return Types in C

A function in C can return a value, and the return type must be specified in the function declaration and definition.

Common Return Types:

Example of Function Returning an int

int add(int a, int b) {
    return a + b; // Returning an integer value
}
            

Example of Function with void Return Type

void printMessage() {
    printf("Hello, World!\n"); // No return value
}